/*
    Clase en la que se crea el m�todo para acceder / conectar a la base de datos
 */

package com.conexion;

import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.ResourceBundle;

import com.mysql.jdbc.Connection;

public class DbConnection {

	private static ResourceBundle rb = ResourceBundle
			.getBundle("properties/database_conexion");

	public static Connection getConnection() {
		Connection conexion = null;

		try {
			Class.forName(rb.getString("driver"));
			String servidor = rb.getString("url");
			String usuario = rb.getString("username");
			String pass = rb.getString("password");
			conexion = (Connection) DriverManager.getConnection(servidor,
					usuario, pass);
		} catch (ClassNotFoundException e) {
			System.out.println("Error " + e);
			conexion = null;
		} catch (SQLException e) {
			System.out.println("Error " + e);
			conexion = null;
		} catch (Exception e) {
			System.out.println("Error " + e);
			conexion = null;
		}
		return conexion;
	}

}
